// 获取数据
const getCloudData = (gather, params = {}) => {
  return new Promise((resolve, reject) => {
    gather.where(params).get({
      success: res => {
        resolve(res.data[0]);
      },
      fail: err => {
        reject(err);
      }
    })
  })
}

// 更新数据
const updateCloudData = (gather, params = {}, data = {}) => {
  return new Promise((resolve, reject) => {
    gather.where(params).update({
      data,
      success: res => {
        resolve(res.data[0]);
      },
      fail: err => {
        reject(err);
      }
    })
  })
}

// 删除云储存文件
const delCloudFile = (fileID) => {
  return new Promise((resolve, reject) => {
    wx.cloud.deleteFile({
      fileList: typeof (fileID) == "string" ? [fileID] : fileID,
      success(res) {
        console.log(res, '删除文件');
      },
      fail(err) {
        console.log(err);
      }
    });
  })
}

module.exports = {
  getCloudData,
  updateCloudData,
  delCloudFile
}
